

import type { Istoreproductattr } from './entity';
import type { IPageParams } from '@/types/table'
import request from '@/api/request'

export function getPageList(params: IPageParams) {
  return request({
    url: `admin/store/product/rule/list`,
    method: 'get',
    params,
    loading: true
  }).then(res => {
    let list = res.list.map(e => {
      e.ruleValue = JSON.parse(e.ruleValue)
      return e
    })
    return { ...res, list }
  })
}

export function storeproductattrDel(id: number) {
  return request({
    url: `/admin/store/product/rule/delete/${id}`,
    method: 'get'
  })
}
export function storeproductattrinfo(id) {
  return request({
    url: `admin/store/product/rule/info/${id}`,
    method: 'get'
  })
}
export function storeproductattrSelect(id) {
  return request({
    url: `admin/store/product/rule/select`,
    method: 'get'
  })
}

export function storeproductattrAddup(data) {
  return request({
    url: `admin/store/product/rule/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data
  })
}
